<template>
  <van-nav-bar
    title="搜索"
    left-text="返回"
    left-arrow
    @click-left="
      () => {
        $router.back('/');
      }
    "
  />
  <van-search
    v-model="sousuoval"
    shape="round"
    placeholder="请输入搜索关键词"
  />
  <template v-if="sousuoval == 0 || sousuoData == 0">
    <van-empty description="暂无搜索数据" />
  </template>
  <template v-else>
    <van-cell-group v-for="i in sousuoData">
        <router-link :to="'/xiangqing/'+i.goods_id">
            <van-cell :title="i.goods_name" />
        </router-link>
    </van-cell-group>
  </template>
</template>


<script setup>
import { ref,watch } from "vue";
import { sousuoApi } from "@/api/api";
let sousuoData = ref([]);
let sousuoval = ref("");
import _ from 'lodash'
watch(sousuoval,_.debounce((sousuoval)=>{
    sousuoApi(sousuoval).then(res=>{
        console.log('搜索',res);
        sousuoData.value=res.data.message
    })
},2000)
)
</script>

<style lang="scss" scoped>
</style>